package sketch.generator.experiment;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import sketch.util.Checker;

public abstract class ValueGroup<T> {
	
	public final List<T> data = new ArrayList<T>();
	
	public ValueGroup(Collection<T> data) {
		this.checkDataValidity(data);
		this.addData(data);
	}
	
	public ValueGroup(T...data) {
		this.checkDataValidity(data);
		this.addData(data);
	}
	
	protected void addData(Collection<T> data) {
		for(T d : data) {
			this.data.add(d);
		}
	}
	
	protected void addData(T...data) {
		for(T d : data) {
			this.data.add(d);
		}
	}
	
	public List<T> getData() {
		return this.data;
	}
	
	public T getSingleData() {
		Checker.checkTrue(this.isSingleData(), "Valid only when this object is a single value");
		return this.data.get(0);
	}
	
	@Override
	public String toString() {
		return this.data.toString();
	}
	
	protected abstract void checkDataValidity(Collection<T> data);
	
	protected abstract void checkDataValidity(T... data);
	
	public abstract boolean isSingleData();
	
	public abstract boolean isEmptyData();
	
	public abstract boolean isMultiData();
}